
#include "StreamDetailWidget.h"

StreamDetailWidget::StreamDetailWidget(void)
{
	createInterface();
}

StreamDetailWidget::~StreamDetailWidget(void)
{
}

void StreamDetailWidget::createInterface()
{
	QHBoxLayout *pSubLayout = new QHBoxLayout();
	setTitle(tr(TITLE_SECTION_INFO));

	QVBoxLayout *pSubLayout1 = new QVBoxLayout();
	QWidget *subWidget1 = new QWidget();
	QVBoxLayout *pSubLayout2 = new QVBoxLayout();
	QWidget *subWidget2 = new QWidget();
	m_lblSlotId = new QLabel(tr(LABEL_SLOT_ID));
	m_lblHash = new QLabel(tr(LABEL_HASH));
	m_lblTimeStart = new QLabel(tr(LABEL_START));
	m_lblTimeEnd = new QLabel(tr(LABEL_END));
	m_lblCustId = new QLabel(tr(LABEL_CUSTOMER));
	m_lblProvId = new QLabel(tr(LABEL_PROVIDER));
	m_lblTestMode = new QLabel(tr(LABEL_MODE));
	m_lblAvailable = new QLabel(tr(LABEL_AVAILABLE));
	pSubLayout1->addWidget(m_lblSlotId);
	pSubLayout1->addWidget(m_lblHash);
	pSubLayout1->addWidget(m_lblTimeStart);
	pSubLayout1->addWidget(m_lblTimeEnd);
	pSubLayout1->setContentsMargins(2, 0, 0, 0);
	subWidget1->setLayout(pSubLayout1);
	pSubLayout2->addWidget(m_lblCustId);
	pSubLayout2->addWidget(m_lblProvId);
	pSubLayout2->addWidget(m_lblTestMode);
	pSubLayout2->addWidget(m_lblAvailable);
	pSubLayout2->setContentsMargins(2, 0, 0, 0);
	subWidget2->setLayout(pSubLayout2);
	pSubLayout->addWidget(subWidget1);
	pSubLayout->addWidget(subWidget2);
#if !defined(_WIN32) && !defined(_WIN64)
	pSubLayout->setContentsMargins(0, 5, 0, 5);
#endif
	setLayout(pSubLayout);
}

void StreamDetailWidget::update(const IceCastSlot *slot)
{
	if (0 == slot)
		return;

	m_lblSlotId->setText(QString(LABEL_SLOT_ID) + QString::number(slot->id));
	m_lblHash->setText(QString(LABEL_HASH) + QString(slot->hash));
	m_lblTimeStart->setText(QString(LABEL_START) + slot->timeStart);
	m_lblTimeEnd->setText(QString(LABEL_END) + slot->timeEnd);
	m_lblCustId->setText(QString(LABEL_CUSTOMER) + QString::number(slot->customerid));
	m_lblProvId->setText(QString(LABEL_PROVIDER) + QString::number(slot->providerid));
	m_lblTestMode->setText(QString(LABEL_MODE) + QString::number(slot->testmode));
	m_lblAvailable->setText(QString(LABEL_AVAILABLE) + (slot->available ? "Yes" : "No"));
}

